package com.xored.glance.internal.actions;

import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;

import com.xored.glance.internal.core.GlancePlugin;

/**
 * @author Yuri Strot
 */
public class CheckAction extends Action {

	public CheckAction(String text, String id, String path) {
		super(text, AS_CHECK_BOX);
		ImageDescriptor image = GlancePlugin.imageDescriptorFromPlugin(
				GlancePlugin.PLUGIN_ID, path);
		setImageDescriptor(image);
		setId(id);
		setChecked(getPreferences().getBoolean(getId()));
	}

	protected Preferences getPreferences() {
		return GlancePlugin.getDefault().getPluginPreferences();
	}

	@Override
	public void run() {
		doRun();
		getPreferences().setValue(getId(), isChecked());
	}

	protected void doRun() {
	}
}
